home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-29 | 2.5 KB | 83 lines | [TEXT/CWIE] |
- //================================================================================
- // Greg Anderson
- // db+
- //
- // Abstract base class for update pointers
- // 16 May 1994
- //================================================================================
- #pragma once
-
- #ifndef __ABSTRACTUPDATEPOINTER__
- #define __ABSTRACTUPDATEPOINTER__
-
- #include "TransactionAwareObject.h"
-
- #include "Int64.h"
-
- //
- // For REQUIREVALIDPOINTER
- //
- #include "Debug.h"
-
- //
- // Still needed?
- //
- #include "Exceptions.h"
-
- //
- // Our abstract update pointer class knows about all of
- // the classes of objects that may have update pointers
- // so that it may provide type-safe downcasting.
- //
- class TAbstractRecord;
- class TBlockDataRecord;
- class TDBRecordUpdatePointer;
- class TDBElementUpdatePointer;
- class TDBPropertyUpdatePointer;
-
- //================================================================================
- // class TAbstractUpdatePointer
- //
- // We want a base class for our update pointers so that we can have a typeless
- // base class for our update pointer collection
- //================================================================================
- class TAbstractUpdatePointer : public TTransactionBaseObject
- {
- //
- // A transaction is a friend of an update pointer, because only
- // transactions may call commit and discard changes on an update pointer
- //
- friend class TTransaction;
-
- private:
- const TTransaction* fTransaction;
-
- public:
- TAbstractUpdatePointer(const TTransaction* transaction) : fTransaction(transaction) { REQUIREVALIDPOINTER(transaction); };
- virtual ~TAbstractUpdatePointer();
-
- virtual TTransactionAwareObject* ChangeObject() const = 0;
-
- virtual TDBRecordUpdatePointer* DBRecordUpdatePointer();
- virtual TDBElementUpdatePointer* ObjectRecordUpdatePointer();
- virtual TDBPropertyUpdatePointer* DataRecordUpdatePointer();
-
- //
- // Most methods inherited from TTransactionAwareObject
- // call through to the object being changed
- //
- virtual Int64 ObjectsKeySpace() const { return this->ChangeObject()->ObjectsKeySpace(); };
- virtual long ObjectKey() const { return this->ChangeObject()->ObjectKey(); };
-
- protected:
- //
- // Only an object's update pointer may call its Commit / Discard changes methods
- //
- // ◊const TTransaction* cast away; should we remove the 'const' from fTransaction entirely?
- //
- virtual void CommitChanges() { this->ChangeObject()->CommitChanges((TTransaction*)fTransaction); };
- virtual void DiscardChanges() { this->ChangeObject()->DiscardChanges((TTransaction*)fTransaction); };
- };
-
- #endif
-